unit uFormLogin;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, sBitBtn, sBevel, sEdit,  uUIFormPlugin,
  sComboBox, sLabel, StdCtrls, Buttons, ExtCtrls;

type
  TFormLogin = class(TUIPluginForm)
    btnLogin: TsBitBtn;
    btnExit: TsBitBtn;
    Gp: TGroupBox;
    sLabel1: TsLabel;
    sLabel2: TsLabel;
    sLabel3: TsLabel;
    cbbType: TsComboBox;
    edtPassWord: TsEdit;
    edtUserName: TsEdit;
    procedure FormKeyPress(Sender: TObject; var Key: Char);
    procedure btnExitClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure edtUserNameKeyPress(Sender: TObject; var Key: Char);
    procedure edtPassWordKeyPress(Sender: TObject; var Key: Char);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FormLogin: TFormLogin;

implementation

{$R *.dfm}

{ TFormLogin }

procedure TFormLogin.FormKeyPress(Sender: TObject; var Key: Char);
begin
  if Key = #27 then Self.Close;
end;

procedure TFormLogin.btnExitClick(Sender: TObject);
begin
  Self.Close;
end;

procedure TFormLogin.FormShow(Sender: TObject);
begin
  if Trim(edtUserName.Text) = '' then
  begin
    if edtUserName.CanFocus then
    begin
      edtUserName.SetFocus;
      Exit;
    end;
  end;
end;

procedure TFormLogin.edtUserNameKeyPress(Sender: TObject; var Key: Char);
begin
  if Key = #13 then
  begin
    if Trim(edtUserName.Text) <> '' then
    begin
      if edtPassWord.CanFocus then
      begin
        edtPassWord.SetFocus;
      end;
    end;
  end;
end;

procedure TFormLogin.edtPassWordKeyPress(Sender: TObject; var Key: Char);
begin
  if Key = #13 then
  begin
    if btnLogin.CanFocus then
    begin
      btnLogin.SetFocus;
    end;
  end;
end;

end.
